#include "StdAfx.h"
#include "PrimitiveCube.h"

using namespace std;

namespace FEngine
{
	PrimitiveCube::PrimitiveCube(float _size)
		: Primitive()
	{
		// Generate the vertices
		vector<Vector3> verticesVector;
		verticesVector.push_back(Vector3(-_size, _size, _size));
		verticesVector.push_back(Vector3(_size, _size, _size));
		verticesVector.push_back(Vector3(_size, _size, -_size));
		verticesVector.push_back(Vector3(-_size, _size, -_size));
		verticesVector.push_back(Vector3(-_size, -_size, _size));
		verticesVector.push_back(Vector3(_size, -_size, _size));
		verticesVector.push_back(Vector3(_size, -_size, -_size));
		verticesVector.push_back(Vector3(-_size, -_size, -_size));
		
		// Generate the indexes
		vector<unsigned int> indexesVector;
		indexesVector.push_back(0); indexesVector.push_back(1); indexesVector.push_back(2);
		indexesVector.push_back(2); indexesVector.push_back(3); indexesVector.push_back(0);
		indexesVector.push_back(5); indexesVector.push_back(4); indexesVector.push_back(7);
		indexesVector.push_back(7); indexesVector.push_back(6); indexesVector.push_back(5);
		
		indexesVector.push_back(3); indexesVector.push_back(2); indexesVector.push_back(6);
		indexesVector.push_back(6); indexesVector.push_back(7); indexesVector.push_back(3);
		indexesVector.push_back(1); indexesVector.push_back(0); indexesVector.push_back(4);
		indexesVector.push_back(4); indexesVector.push_back(5); indexesVector.push_back(1);
		
		indexesVector.push_back(0); indexesVector.push_back(3); indexesVector.push_back(4);
		indexesVector.push_back(3); indexesVector.push_back(7); indexesVector.push_back(4);
		indexesVector.push_back(2); indexesVector.push_back(1); indexesVector.push_back(5);
		indexesVector.push_back(5); indexesVector.push_back(6); indexesVector.push_back(2);

		_createGeometry(verticesVector, indexesVector, D3DPT_TRIANGLELIST);
	}

	PrimitiveCube::~PrimitiveCube()
	{
	}

} // namespace FEngine
